package cn.cosmosx.base.security.filter;

import cn.cosmosx.base.security.dynamic.DynamicAccessDecisionManager;
import cn.cosmosx.base.security.dynamic.DynamicFilterInvocationSecurityMetadataSource;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.stereotype.Component;

/**
 * SpringSecurity自定义动态权限过滤安全拦截器。
 * 将自定义权限动态元数据获取器及动态权限处理管理器注册到此过滤器中
 */
@Component
public class CustomFilterSecurityInterceptor extends FilterSecurityInterceptor {

    /**
     * 将自定义权限动态元数据获取器及动态权限处理管理器注册到过滤器中
     *
     * @param source   - 动态权限获取实现
     * @param decision - 用户权限处理
     */
    public CustomFilterSecurityInterceptor(DynamicFilterInvocationSecurityMetadataSource source,
                                           DynamicAccessDecisionManager decision) {
        super.setSecurityMetadataSource(source);
        super.setAccessDecisionManager(decision);
    }
}
